// Copyright 2008-2009 Louis DeJardin - http://whereslou.com
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
using System.Collections.Generic;
using Spark.Compiler;
using Spark.Compiler.ChunkVisitors;
using Spark.Parser.Code;

namespace NRails.Spark.ChunkVisitors
{
    public class FileReferenceVisitor : ChunkVisitor
    {
        private _references : IList[RenderPartialChunk] = List.[RenderPartialChunk]();

        //refactor: see how this is used and change it's type
        public References : IList[RenderPartialChunk]
        {
            get { _references; }
        }

        protected override Visit(chunk : RenderPartialChunk) : void
        {
            References.Add(chunk);
            Accept(chunk.Body);
            foreach (chunks in chunk.Sections.Values)
                Accept(chunks);
        }

        protected override Visit(chunk : UseImportChunk) : void
        {
            def s1 = RenderPartialChunk();
            s1.Name = chunk.Name : Snippets;
            References.Add(s1);
        }
    }
}